package com.yd.app.service.mobile.couponService;

import com.yd.app.mapper.CouponMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.Coupon;
import com.yd.domain.business.UserCoupon;
import com.yd.domain.commom.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 优惠券Service
 * Created by sunxianhui on 2018/3/9.
 */
@Service
public class MCouponService extends BaseService {
    @Autowired
    CouponMapper couponMapper;

    /**
     * 添加优惠券
     *
     * @param coupon
     */
    public int addCoupon(Coupon coupon) {
        return couponMapper.addCoupon(coupon);
    }

    /**
     * 修改
     *
     * @param coupon
     */
    public void updateCoupon(Coupon coupon) {
        couponMapper.updateCoupon(coupon);
    }

    /**
     * 删除
     *
     * @param id
     */
    public void deleteCouponByid(String id) {
        couponMapper.deleteCouponById(id);
    }

    /**
     * 根据条件分页查询
     * @return
     */
    public List<UserCoupon> getCouponList(String userId) {
        List<UserCoupon> couponList=new ArrayList<>();
        couponList = couponMapper.getUserCouponList(userId);
        return couponList;
    }
}